
load("~/Dropbox/professional/Research/Active/SciInRegs/Papers/Network/Analysis/networkClean.RData")
library(sna)

nodes <- nodeTitles

amat <- symmetrize(amat)

#write.csv(cbind(nodeTitles,""),"~/Dropbox/professional/Research/Active/SciInRegs/Papers/Network/Analysis/nodeList.csv",row.names=F)

library(colorRamps)
require(sna)

grange <- range(which(substr(nodes,1,2)=="g_")) # regulations
jrange <- range(which(substr(nodes,1,2)=="j_"))	# journals
rrange <- range(which(substr(nodes,1,2)=="r_"))	# articles
srange <- range(which(substr(nodes,1,2)=="s_")) # scientists
frange <- range(which(substr(nodes,1,2)=="f_")) # funders
arange <- range(which(substr(nodes,1,2)=="a_")) # agencies
crange <- range(which(substr(nodes,1,2)=="c_")) # committees
urange <- range(which(substr(nodes,1,2)=="u_")) # affiliations

# Node names
gnames <- nodes[grange[1]:grange[2]] # regulations
jnames <- nodes[jrange[1]:jrange[2]]	# journals
rnames <- nodes[rrange[1]:rrange[2]]	# articles
snames <- nodes[srange[1]:srange[2]] # scientists
fnames <- nodes[frange[1]:frange[2]] # funders
anames <- nodes[arange[1]:arange[2]] # agencies
cnames <- nodes[crange[1]:crange[2]] # committees
unames <- nodes[urange[1]:urange[2]] # affiliations


library(networksis)

artRIABipartite <- amat[(rrange[1]:rrange[2]),(grange[1]:grange[2])]
artRIANet <- network(artRIABipartite)
artRIANet %v% "set" <- c(rep(1,length(rnames)),rep(2,length(gnames)))
system.time(simNets <- simulate(artRIANet,nsim=40,save.networks=T,seed = 300000))
save(list="simNets",file="~/Dropbox/professional/Research/Active/SciInRegs/Papers/Network/Analysis/SimNets3.RData")


